
public class Deck {
	
	char cardname[] = {'2','3','4','5','6','7','8','9','T','J','Q','K','A'};
	int  cardrank[] = {0,1,2,3,4,5,6,7,8,9,10,11,12};
	char cardsuit[] = {'C','D','H','S'};
	String carddeck[] = new String[52];
	String  pilelist[];
	
	Deck()
	{
		
		int x = 0;
		
		for (int fillsuit = 0; fillsuit <4; fillsuit++)
		{
			for (int fillcard =0;fillcard<13;fillcard++)
			{
				carddeck[x] = Integer.toString(fillcard);
				x++;
			}
		}
	}
	
	void shuffle()
	{
		int currentshufflecount = 1;
		while ( currentshufflecount <= 5+(int)(Math.random()*6) )//shuffle at least 5 times and at most 10 times
		{
			for (int i = 0;i<carddeck.length;i++)
			{
			
				int indexofsecondcard = (int)(Math.random()*carddeck.length);
				String tempindex = carddeck[i];
				
				 
				carddeck[i] = carddeck[indexofsecondcard];
				carddeck[indexofsecondcard] = tempindex;
				
			
			}
			currentshufflecount++;
		}
		
	}

	void makePile() // by default , make 4 piles
	{
	
		pilelist = new String[5];
		for (int i = 1 ;i<=4 ;i++)
		{
			pilelist[i] = carddeck[i-1];
		}
	}
	
	void makePile(int totalpileinput) 
	{

		pilelist = new String[totalpileinput +1];
		for (int i = 1 ;i<=totalpileinput ;i++)
		{
			pilelist[i] = carddeck[i-1];
		}
		
	}
	
	char toCardName(int choosencard)
	{

		return cardname[choosencard];
		
	}
	
	
	}


